home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Libsprintf / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-15  |  1.7 KB  |  66 lines  |  [TEXT/KAHL]

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #include "libsprintf.h"
  6.  
  7. #if defined(powerc)||defined(__powerc)
  8. #define kNumLoops 0x00100000
  9. #else
  10. #define kNumLoops 0x00001000
  11. #endif
  12.  
  13. int main(void){
  14.     char buf[4096];
  15.     unsigned long start,stop,tapple=0L,tlib=0L;
  16.     register long loop;
  17.     long top=kNumLoops;
  18.     
  19.     printf("\n\nSprintf speed tests\n\n");
  20.     
  21.     printf("Performing %ld string expansions\n\n",top);
  22.     
  23. #if 1
  24.     printf("Beginning Symantec lib test\n");
  25.     sprintf(buf,"Expanding a number %d, a character %c, a C string [%s] and a pascal string [%#s]\n\n",500,'a',"Test String","\pPascal String");
  26.     printf("Buffer expands to [%s], strlen %d\n\n",buf,strlen(buf));
  27.     
  28.     fflush(stdout);
  29.     
  30. #if 1
  31.     ReadDateTime(&start);
  32.     for (loop=0L;loop<top;loop+=0x00000001){
  33.         sprintf(buf,"Expanding a number %ld, a character %c, a C string [%s] and a pascal string [%#s]\n",loop,'a',"Test String","\pPascal String");
  34.     }
  35.     ReadDateTime(&stop);
  36.     tapple=stop-start;
  37.     
  38.     printf("\nDone with Symantec lib\n\n");
  39. #endif
  40.     
  41. #endif
  42.  
  43.     printf("Beginning lib test\n");
  44.     libsprintf(buf,"Expanding a number %ld, a character %c, a C string [%s] and a pascal string [%#s]\n\n",500,'a',"Test String","\pPascal String");
  45.     printf("Buffer expands to [%s], strlen %d\n\n",buf,strlen(buf));
  46.     
  47.     fflush(stdout);
  48.  
  49. #if 1
  50.     ReadDateTime(&start);
  51.     for (loop=0L;loop<top;loop+=0x00000001){
  52.         libsprintf(buf,"Expanding a number %ld, a character %c, a C string [%s] and a pascal string [%#s]\n",loop,'a',"Test String","\pPascal String");
  53.     }
  54.     ReadDateTime(&stop);
  55.     tlib=stop-start;
  56.     
  57.     printf("\nDone with lib\n\n");
  58. #endif
  59.     
  60.     printf("Results:\n\tSymantec time %lu\n\tlibsprintf time %lu\n",tapple,tlib);
  61.     fflush(stdout);
  62.     
  63.     return 0;
  64. }
  65.  
  66.